Imports SpeechLib
Public Class frmSplash
    Dim voice

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        voice = New SpVoice
        voice.speak("Hello, Welcome to the talking battery monitor")
        Me.Hide()
        Timer1.Enabled = False
    End Sub

    Private Sub ExitToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        voice = New SpVoice
        voice.speak("Good bye")
        End
    End Sub

    Private Sub HideApplicationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideApplicationToolStripMenuItem.Click
        voice = New SpVoice
        voice.speak("Application hidden to tray")
        frmBatMon.Hide()
    End Sub

    Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
        voice = New SpVoice
        voice.speak("Application un-hidden")
        frmBatMon.Show()
    End Sub

    Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
        frmBatMon.Opacity = 0.4
    End Sub

    Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
        frmBatMon.Opacity = 0.5
    End Sub

    Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click
        frmBatMon.Opacity = 0.6
    End Sub

    Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
        frmBatMon.Opacity = 0.7
    End Sub

    Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click
        frmBatMon.Opacity = 0.8
    End Sub

    Private Sub ToolStripMenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem8.Click
        frmBatMon.Opacity = 0.9
    End Sub

    Private Sub ToolStripMenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem9.Click
        frmBatMon.Opacity = 1
    End Sub

    Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
        Dim remaining As String
        Dim ps As PowerStatus = SystemInformation.PowerStatus
        Dim stat As String
        Dim ts As New TimeSpan(0, 0, ps.BatteryLifeRemaining)
        Dim talk As String

        voice = New SpVoice

        If ts.TotalSeconds < 1 Then
            remaining = "Unlimited"
        Else
            remaining = ts.ToString
        End If
        stat = ps.BatteryChargeStatus.ToString

        NotifyIcon1.BalloonTipText = "AC-Power: " & ps.PowerLineStatus.ToString & vbCrLf & "Status: " & stat & vbCrLf & "Remaining: " & ps.BatteryLifePercent * 100 & "%" & vbCrLf & "Time Left: " & remaining
        NotifyIcon1.ShowBalloonTip(1)

        talk = "AC Power is " & ps.PowerLineStatus.ToString & ", Battery status is " & stat & ", and the battery is at " & ps.BatteryLifePercent * 100 & "% charge, there is an estimate of " & remaining & " battery life remaining"

        voice.speak(talk)
    End Sub
End Class